<template>
  <div
    class="right-setting-box"
    :class="{ 'right-setting-box-actived': menuShow }"
  >
    <div class="right-setting-info">
      <img
        :src="'https://image.xuexiwangzhe.com/' + data.userAvatar"
        class="right-setting-info-avatar"
      />
      <div class="right-setting-info-name">{{ data.nickName }}</div>
    </div>
        <div class="right-setting-item" @click="redirectSettings">

      <div class="right-setting-item-left">
        <img
          src="https://image.xuexiwangzhe.com/FlLdtSlrchCAE3ZXE3MHBGgpuPpl"
          class="right-setting-item-left-img"
        />
        <div>账号设置</div>
      </div>
      <img
        src="https://image.xuexiwangzhe.com/FupzIL6jVqOp-JnOuNLK8eDUWeV0"
        class="right-setting-item-right-img"
      />
    </div>
    <div class="right-setting-item">
      <div class="right-setting-item-left">
        <img
          src="https://image.xuexiwangzhe.com/FpT8WFxhG3FDXyiWxITZv6q2LCuO"
          class="right-setting-item-left-img"
        />
        <div>宜训官网</div>
      </div>
      <img
        src="https://image.xuexiwangzhe.com/FupzIL6jVqOp-JnOuNLK8eDUWeV0"
        class="right-setting-item-right-img"
      />
    </div>
    <div class="right-setting-logout" @click="logOut">
      <div class="right-setting-item-left">
        <img
          src="https://image.xuexiwangzhe.com/FhgdBtsdDPwiPBozJezDUS7tXUnl"
          class="right-setting-item-left-img"
        />
        <div>退出登录</div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    data: Object,
  },
  data() {
    return {
      menuShow: false,
    };
  },
  methods: {
    toggleSetMenu() {
      this.menuShow = !this.menuShow;
    },
    openSetMenu() {
      this.menuShow = true;
    },
    closeSetMenu() {
      this.menuShow = false;
    },
    // 退出登录
    logOut() {
      sessionStorage.removeItem("SESSIONKEY");
      location.href = "newLogin.html";
    },
    // 账号设置
    redirectSettings() {
      location.href = "user.html";
    },
  }
};
</script>

<style lang="less" scoped>
.right-setting-box {
  position: absolute;
  top: 35px;
  right: 0;
  width: 203px;
  background: #ffffff;
  box-shadow: 0px 2px 6px 0px rgba(102, 102, 102, 0.2);
  border-radius: 11px;
  padding: 21px 15px 0 21px;
  z-index: -1;
  transform: translateY(-15px);
  transition: transform 0.1s;
  opacity: 0;
}

.right-setting-box-actived {
  opacity: 1;
  transform: translateY(0);
  transition-duration: 0.25s;
  z-index: 1000;
}

.right-setting-info {
  margin-bottom: 25px;
}

.right-setting-info-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  margin: 0 auto;
  display: block;
  object-fit: cover;
  margin-bottom: 6px;
}

.right-setting-info-name {
  text-align: center;
  color: #333;
  font-size: 17px;
  font-weight: bold;
}

.right-setting-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  cursor: pointer;
}

.right-setting-item-left {
  display: flex;
  align-items: center;
  color: #333;
  font-size: 12px;
}

.right-setting-item-left-img {
  width: 15px;
  margin-right: 6px;
}

.right-setting-item-right-img {
  width: 17px;
}

.right-setting-logout {
  padding-top: 14px;
  padding-bottom: 21px;
  border-top: 1px solid #f2f2f2;
  cursor: pointer;
}
</style>
